#include<iostream>
#include<vector>
#include<unordered_map>

using namespace std;

/**/

int similarPairs(vector<string>& words) {
    int res = 0;
    unordered_map<int, int> cnt;
    for (string& s : words) {
        int status = 0;
        for (char& c : s) {
            status |= 1 << (c - 'a');
        }
        res += cnt[status];
        cnt[status]++;
    }
    return res;
}

int main()
{
    vector<string> arr = { "aba","aabb","abcd","bac","aabc" };
    cout << similarPairs(arr) << endl;
    return 0;
}